package server.models.posteDeTir;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Observable;

import rmi.RemoteObserver;
import rmi.WrappedObserver;
import server.models.tireur.ITireur;

public class PosteDeTir extends Observable implements Serializable, IPosteDeTir {
	
	private static final long serialVersionUID = 1L;
	
	private int numero;
	private ArrayList<ITireur> listeTireurs = new ArrayList<ITireur>();
	
	public PosteDeTir(int numero) {
		this.numero = numero;
	}
	
	public PosteDeTir(IPosteDeTir posteDeTir) throws RemoteException {
		this.numero = posteDeTir.getNumero();
	}

	public int getNumero() throws RemoteException {
		return numero;
	}

	public void setNumero(int numero) {
		this.numero = numero;
	}

	public ArrayList<ITireur> getListeTireurs() throws RemoteException {
		return listeTireurs;
	}
	
	public void ajouterTireur(ITireur tireur) throws RemoteException{
		this.listeTireurs.add(tireur);
		this.setChanged();
		this.notifyObservers();
	}
	
	public void clearJoeur() throws RemoteException {
		this.listeTireurs.clear();
		this.setChanged();
		this.notifyObservers();
	}

	@Override
	public void addObserver(RemoteObserver remoteObserver)
			throws RemoteException {
		this.addObserver(new WrappedObserver(remoteObserver));
		
	}
}
